package com.tensquare.gateway.service.impl;

import com.tensquare.entity.Result;
import com.tensquare.entity.StatusCode;
import com.tensquare.gateway.client.UserClient;
import com.tensquare.gateway.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

@Service
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private UserClient userClient;

    @Override
    public boolean checkPermission(String account, String url) {
        Result result = userClient.getPermission(account,url);
        if (result.getCode() == StatusCode.OK) {
            return (boolean) result.getData();
        }
        return false;
    }
}
